﻿@model ArivisTests.Models.TestCase
@using ArivisTests.Models;

@{
    ViewBag.Title = "Edit";
    
    IEnumerable<UserProfile> dbUsers = ViewBag.Users;
    int modelUserId = Model.User == null ? -1 : Model.User.UserId;
    var users = dbUsers.ToList().Select(x => new SelectListItem() { Value = x.UserId.ToString(), Text = x.UserName, Selected = x.UserId == modelUserId }).ToList();
    users.Insert(0, new SelectListItem() { Value = "-1" });
   
    IEnumerable<TestResult> dbResults = ViewBag.Results;
    int modelResultId = Model.Result == null ? -1 : Model.Result.Id;
    var results = dbResults.ToList().Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Name, Selected = x.Id == modelResultId }).ToList();
    results.Insert(0, new SelectListItem() { Value = "-1" });
}

@section Navigation{
    @Html.ActionLink("Test Runs", "Index")
    &rsaquo;
    @Html.ActionLink(Model.Run.Name, "Details", "TestRun", new { id = Model.Run.Id }, null)
    &rsaquo;
    @Html.DisplayFor(model => model.Scenario.Name)
}

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>TestCase</legend>
        @Html.HiddenFor(model => model.Id)
        @Html.Hidden("UrlReferrer", (object)ViewBag.UrlReferrer)
        @Html.Partial("_EditTestCase", this.Model)
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<p>
    @Html.ActionLink("View", "Details", new { id = Model.Id }) |
    @Html.ActionLink("Delete", "Delete", new { id = Model.Id })
</p>

